

import 'package:elevator/model/alerm_info.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

Widget spaceHeight({double height = 10}) {
  return SizedBox(height: height,);
}

Widget spaceWidth({double width = 10}) {
  return SizedBox(width: width,);
}

Widget createVerticalDivider({double w = 1,Color color = Colors.black}){
  return SizedBox(
    width: w,
    height: double.infinity,
    child: DecoratedBox(
      decoration: BoxDecoration(color: color),
    ),
  );
}

Widget createDivider({double h = 1,Color color = Colors.black}){
  return SizedBox(
    width: double.infinity,
    height:  h,
    child: DecoratedBox(
      decoration: BoxDecoration(color: color),
    ),
  );
}

///构建电梯警告信息
getAlermInfoWidgets(List<AlermInfo> list) {

  var width = (Get.width-20) / 6;
  List<Widget> listWidget = [];
  var size = list.length;

  for (int i = 0; i < size; i++) {
    var alarm = list[i];
    if (i != 0) {
      listWidget.add(
          Container(width: 1, height: 48, color: Colors.black,));
    }
    Color color = alarm.getBgColor();
    listWidget.add(
        SizedBox(
            width :width, child:
        Container(
            color: color, height: 48, child:
        Center(
            child: Text(alarm.getTag())))));
  }
  if (size < 3) {
    for (var i = size; i < 3; i++) {
      listWidget.add(
          Container(width: 1, height: 48, color: Colors.black,));
      listWidget.add(
          SizedBox(
              width :width, child:
          Container(width: 1, height: 48, )));
    }
  }
  return listWidget;
}

AppBar myAppbar({List<Widget>? actions}) {
  return AppBar(
    iconTheme: const IconThemeData(color: Colors.white),
    flexibleSpace: Container(
      decoration: const BoxDecoration(gradient: LinearGradient(colors:[
        Color(0xff0e274a),
        Color(0xff447986)
      ], begin: Alignment.centerLeft, end: Alignment.centerRight)),
    ),
    centerTitle: true,
    title:
    const Image(image: AssetImage("images/logo.png"), width: 100.0),
    actions: actions,
  );
}